/*
 * x86_64/tss.hh - TSS data type and installer function.
 * Copyright (C) 2007  Mikhail Vorozhtsov
 * See the LICENSE section of the README file for details.
 */

/* $Id$ */

#ifndef HEADER_X86_64_TSS_HH
#define HEADER_X86_64_TSS_HH

START_NAMESPACE (x86_64)

struct tss_t
{
  u32_t : 32;
  u64_t rsp0;
  u64_t rsp1;
  u64_t rsp2;
  u64_t : 64;
  u64_t ist1;
  u64_t ist2;
  u64_t ist3;
  u64_t ist4;
  u64_t ist5;
  u64_t ist6;
  u64_t ist7;
  u64_t : 64;
  u16_t : 16;
  u16_t base;
  u8_t iopb[8192] ALIGNED (4096);
  u8_t extra;
} PACKED;

INLINE
static void
set_tr (u16_t selector)
{
  asm volatile (
    "ltr %%ax\n"
    :
    : "a"(selector)
  );
}

END_NAMESPACE

#endif /* HEADER_X86_64_TSS_HH */

